package com.leetcode.字符串;

import java.util.ArrayList;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;


/**
 * @BelongsProject: LeetCode
 * @BelongsPackage: com.leetcode.字符串
 * @Author: lei
 * @CreateTime: 2024-03-11  14:11
 * @Description: TODO
 * @Version: 1.0
 */
public class 坐标移动 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            String[] split = line.split(";");
            ArrayList<Integer> x = new ArrayList<>();
            ArrayList<Integer> y = new ArrayList<>();
            for (String s : split) {
                boolean match = Pattern.compile("^[ASWD]\\d{1,2}$").matcher(s).find();
                if (match) {
                    String startWith = s.substring(0, 1);
                    int j = Integer.parseInt(s.substring(1));
                    switch (startWith) {
                        case "A":
                            x.add(j * -1);
                            break;
                        case "D":
                            x.add(j);
                            break;
                        case "W":
                            y.add(j);
                            break;
                        case "S":
                            y.add(j * -1);
                            break;
                    }
                }

            }
            AtomicInteger xResult = new AtomicInteger();
            AtomicInteger yResult = new AtomicInteger();
            x.forEach(xResult::addAndGet);
            y.forEach(yResult::addAndGet);
            System.out.println("(" + xResult.get() + "," + yResult.get() + ")");
        }
    }
}
